package com.example.designpattern.test.testProtected.test;

import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;

public class Main1 {
    public static void main(String[] args) {
        int amount = 10;
        Integer[] randomArr = getRandomArr(amount, arr -> {
            arr = new Integer[amount];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = (int) (Math.random() * 100) + 1;
            }
            return arr;
        });
        System.out.println(Arrays.toString(randomArr));
        Node root = null;
        for (int i = 0; i < randomArr.length; i++) {

            if (i == 0) {
                root = new Node(randomArr[i]);
                System.out.println("root " + root.key);
            } else {
                Node current = root;
                while (current != null) {
                    System.out.println("current.key " + current.key + "    randomArr[i] " + randomArr[i]);
                    if (randomArr[i] <= current.key) {
                        if (current.left == null) {
                            current.left = new Node(randomArr[i]);
                            System.out.println("current.left.key " + current.left.key);
                            break;
                        } else {
                            current = current.left;
                            System.out.println("current.left.key " + current.key);
                        }
                    } else {
                        if (current.right == null) {
                            current.right = new Node(randomArr[i]);
                            System.out.println("current.right.key " + current.right.key);
                            break;
                        } else {
                            current = current.right;
                            System.out.println("current.right.key " + current.key);
                        }
                    }


                    /*if (randomArr[i] > current.key && current.right == null)
                        current.right = new Node(randomArr[i]);
                    else
                        current = current.right;*/
                }
            }
            String str = "1hello,world1113211141";
            System.out.println(Arrays.toString(str.split("1")));
            List<Integer> integers1 = Arrays.asList(1, 3, 2, 2, 89, 34, 12, 456, 23);
            TreeSet<Integer> integers = new TreeSet<>(integers1);
            System.out.println(integers);
            int iii=999;
            System.out.println(""+iii);

            Scanner input=new Scanner(System.in);
            int n=input.nextInt();
            String num=""+n;
            String result="";
            for(int j=num.length()-1;j>=0;j--){
                result+=num.charAt(j);
            }
            System.out.println(result);
        }
    }

    public static Integer[] getRandomArr(int amount, Function<Integer[], Integer[]> f) {
        return f.apply(null);
    }

}

class Node {
    Integer key;
    Node left;
    Node right;

    public Node() {
    }

    public Node(Integer key) {
        this.key = key;
    }
}
